package com.woniu.p2p.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.p2p.service.MyborrowHistoryService;
import com.woniu.p2p.vo.FindMessageVo;
import com.woniu.p2p.vo.MyborrowHistoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/myborrowHistory")
public class MyborrowHistoryController {

    @Autowired
    MyborrowHistoryService myborrowHistoryService;

    @RequestMapping("/records")
    public PageInfo<MyborrowHistoryVo> findAllMyborrow(@RequestBody FindMessageVo  findMessageVo, HttpServletRequest request){
        String token = request.getHeader("token");
        int i = Integer.parseInt(token);
        Integer pageNum = findMessageVo.getPageNum();
        PageInfo<MyborrowHistoryVo> pageInfo = myborrowHistoryService.findAllUserMonloans(i, pageNum);
        return pageInfo;
    }
}
